import Http from "../http";

export async function macroApi() {
    const { data } = await Http.get('macroeconomic/macr_sort/')
    function reduce(rows, level=0) {
        rows.forEach((row, index) => {
            row.selectable = !row.children || row.children.length == 0
            row.key = `${row.id}_${index}_${level}`
            if(row.children && row.children.length > 0){
                reduce(row.children, level + 1)
            }
        })
    }

    if(data) {
        reduce(data)
    }
    
    return data || []
}

export function macroTestApi(id:number=0) {
    return Http.get('macroeconomic/macroTest/', { id })
}